<template>
	<div>
		<server-question v-on:toParent="changeDescrible" :data="data" :describle="describle" :initData="getInitData"></server-question>
	</div>
</template>

<script>
	import { mapMutations, mapActions, mapGetters } from "vuex";
	import {getPageTree, initDomTree} from "../../../utils/getPageTree";
	import ServerQuestion from "../../../real-components/servers/serverQuestion";
	import { Toast } from '../../../utils/toast.js';
	import {questionList, getUcUserInfo} from '../../../api/wxh/getData.js';
	import {reFreshUserInfo} from '../../../utils/WXH/login.js';
	import axios from 'axios';
	import {zxBase,zxSessionId} from '../../../api/zxApi.js';
//	console.log(zxApi,'zxApi')
	export default {
        props: {
         	
        },
        data () {
            return {
                pageTree: [],
                describle: null,
				data: null
            }
        },
        computed:{
       		...mapGetters('wxh',[
				'sessionId',
				'userInfo'
			])
        },
        mounted(){
			this.initData();
		}
		,
		watch: {
			describle(newValue, oldValue) {
				console.log(newValue, oldValue,'newValue, oldValue')
				this.initData(newValue)
			}
		}
		,
		methods: {
			...mapActions('wxh', [
			  'getUserInfo'
			])
			,
			...mapMutations('wxh', [
			  'USER_INFO',
			  'ClEAR_SESSIONID',
			  'LOGO_OUT',
			  'LOGO_IN',
			  'CLEAR_INFO'
			])
			,
			changeDescrible(val){
				console.log(5656565656,val);
				this.describle = val;
			},
			//对接运营接口
			getInitData(){
				//此接口如果传参就是搜索
				let params = {
					"describle":this.describle,
					"enterpriseCode":window.api.enterpriseCode
        		};
				let config = {
//					http://172.19.5.131:33004   运营本地
//	            	url: window.api.local_host+'/commonQuestionVue/queryAnswerList',
					url:window.api.customer_host +'/commonQuestionVue/queryAnswerList',
	            	method: 'POST',
	            	data: params,
	            	headers: {'sessionId': this.sessionId, 'Content-Type':'application/json', 'Accept' : 'application/json'},
	            }
				axios(config).then((res)=>{
					if(res.data.returnCode == 0) {
						Toast({
						  message: res.errmsg,
						  type: 'fail',
						  duration: 2000
						});
						return
					}
					this.data = res.data.data[0].results;
				})
			},
			async initData(val) {
			
		        //调用個人中心的方法刷新用户信息 防止vuex用户信息失效
				reFreshUserInfo(this);
				//初始化数据
		        this.getInitData();
			}
		},
        components: {
	        "server-question": ServerQuestion,
	    },
       	
    }
</script>

<style>
</style>